package cn.hill4j.tool.spring.ext.iop.feign;

import feign.Feign;
import feign.Target;
import org.springframework.cloud.context.named.NamedContextFactory;

/**
 * FeignIop 处理器
 *
 * @author: hillchen
 * Date: 2023-02-13 15:10
 */
public interface FeignIopTargeter {
    /**
     * @author hillchen
     * Description: 构造feign执行类
     * Date: 2023/8/12 23:00
     * @param <T> 目标执行类类型
     * @param builder feign构造器
     * @param feign feign构造器上下文
     * @param context 命名空间上下文
     * @param target 原始处理器
     * @return T
     **/
    <T> T target(IopFeignClientBuilder builder, Feign.Builder feign,
                 NamedContextFactory context, Target<T> target);
    /**
      * ClassName: FeignIopTargeter
      * Description: 默认的FeignIop 处理器
      * @author hillchen
      * Date: 2023/8/12
      * @version: 1.0
      */
    class DefaultTargeter implements FeignIopTargeter {
        @Override
        public <T> T target(IopFeignClientBuilder builder, Feign.Builder feign, NamedContextFactory context, Target<T> target) {
            return feign.target(target);
        }
    }
}
